<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta charset="UTF-8">
  <title>文明互动</title>
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/common.css">
  <link rel="stylesheet" href="../css/interactive.css">
  <script type="text/javascript" src="../lib/js/evm.js"></script>
  <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
  <script type="text/javascript" src="../lib/js/key.js"></script>
  <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/model.js"></script>
  <style>

  </style>
</head>

<body>
  <div class="volunteer-bg" id="volunteerMain">
    <ul class="nav-bg" id="nav-bg">
    </ul>

    <!-- 下左侧模块 -->
    <!-- <ul id="menu_bg" class="menu-bg">
    </ul> -->


    <div class="list-bg">
      <div class="list-con" id="list-con"></div>
      <p class="page-show" id="page_show"><span id="now_page">0</span>/<span id="total_page">0</span>

      </p>
    </div>

  </div>

  </div>

</body>
<script>
  var modelIndex = {
    disUser: false,
    index: 0, //导航栏初始位置
    menuKey: '',
    menuPageSize: 7, //导航栏模块数量
    pageSize: 1, //主模块数量
    type: '',
    crumbs: leftModel[TV.GetParam("model")].name,
    structure: 2, //上下结构  默认1是左右，2是上下结构
    menuContainerId: 'nav-bg', //包含导航栏模块的标签id
    menuListName: 'nav', //导航栏模块名称class
    mainContainerId: 'list-con', //包含主模块的标签id
    mainlistName: '', //主模块名称
    model_api: '', //当前模块的api路径
    model_detail: '', //当前模块去往的页面
    id: leftModel[TV.GetParam("model")],
  }

  var leftData = leftModel[TV.GetParam("model")].arry;





  function getMenus(page, number) {
    if (typeof number == 'number') {
      // modelIndex.mainContainerId = leftData[number].list_name;
    }
    left.paint(page, number);
    $(".nav").css("width",(1/leftData.length)*100+"%")

  }

  function getMessage(id, page, pos, index) { //id,类型，页码，上下页，位置
    console.log(id, page, pos, index, modelIndex.menuKey)
    if (modelIndex.model_api == 'getAreaRank') { //积分排行榜
      $('.page-show').css('display', 'none')
      $('.list-bg').css('background', 'transparent')
      console.log(modelIndex.menuKey)
      var str = '';
      var data1 = [];
      var data2 = [];
      var params1 = {
        level: 4
      }
      GetDatas(modelIndex.model_api, params1, function (err, res) {
        data1 = res.data;
      })
      var params2 = {
        level: 5
      }
      GetDatas(modelIndex.model_api, params2, function (err, res) {
        console.log(res.data)
        data2 = res.data;
        console.log(data1, data2)
        str += '<div class="list-rank-container">'
        for (var i = 0; i < data1.length; i++) {
          str += '<div class="list-rank"><span class="rank">' + data1[i].rank + '</span><span class="address">' + data1[i].Name + '</span><span class="score">' + data1[i].score + '</span></div>'
        }
        str += '</div>'
        str += '<div class="list-rank-container">'
        for (var i = 0; i < data2.length; i++) {
          str += '<div class="list-rank"><span class="rank">' + data2[i].rank + '</span><span class="address">' + data2[i].Name + '</span><span class="score">' + data2[i].score + '</span></div>'
        }
        str += '</div>'
        $('#' + modelIndex.mainContainerId).html(str);
      })
    }
    else if (modelIndex.model_api=="getShop") {  //文明积分
      $('.list-bg').css('background', 'rgba(0,0,0,.2)')
      var param = {
        page: page,
        pagesize: modelIndex.pageSize,
        // id: 895,
        // area_id: $.cookie('TV_CST_AREA'),
        // device: 'tv'
      }
      GetDatas(modelIndex.model_api, param, function (err, res) {
        var mess = res.data;
        var str = '';
        console.log(mess)
        if (mess.items.length > 0) {
          $('#page_show').css('display', 'block');
          for (var i = 0; i < mess.items.length; i++) {
            var img = '';
            if (!mess.items[i].img) {
              img = '../images/base.png'
            } else {
              img = API_URL.imgURL + mess.items[i].img
            }
            str += "<div class='list-video' data-id=" + mess.items[i].id + " data-tpe=" + mess.items[i].tpe + " >";
            //通过数组的方式 将所有的对应项都输出来
            str += '<div class="list-imgBar">'
            str += "<img class='list-img' src=" + img + ">";
            str += '</div>'
            if (mess.items[i].tpe == 5 || mess.items[i].tpe == 4) {
              str += "<div class='listPlay' ><img src='../images/play.png'></div>";
            }
            str += "<div class='list-name'>" + mess.items[i].name + '</div>'
            str += "<div class='list-title'><p class='ell'>兑换  " + mess.items[i].integral + ' 分</p></div>'
            str += '</div>'
          }
        } else {
          str += '<h1>暂无数据</h1>';
          $('#page_show').css('display', 'none');
        }
        $('#now_page').html(page)
        $('#total_page').html(mess.totalpage)
        $('#' + modelIndex.mainContainerId).html(str);
        MessOpt(page, mess.totalpage, pos, index);
      })
    }
    else if (modelIndex.model_api == 'getArticleList') { //实践直播
      $('.list-bg').css('background', 'rgba(0,0,0,.2)')
      var params = {
        cid: 66,
        page: page,
        pagesize: modelIndex.pageSize,
        month: modelIndex.menuKey || ''
        // area_id: $.cookie('TV_CST_AREA')
      }

      GetDatas(modelIndex.model_api, params, function (res, data) {
        var mess = data.data;
        console.log(mess.items)
        var str = '';
        if (mess.items.length) {
          $('.page-show').css('display', 'block')
          for (var i = 0; i < mess.items.length; i++) {
            str += '<div class="' + modelIndex.mainlistName + '" data-id=' + mess.items[i].id + " data-tpe=" + mess.items[i].tpe + " >";
            if (modelIndex.mainlistName == 'list-row') {
              str += '<div class="list-info">'
              //图片                      
              var img = '';
              var image = '';
              if (mess.items[i].thumb_img == '') {
                img = '../images/base.png'
              } else {
                img = API_URL.imgURL + mess.items[i].thumb_img
                image = API_URL.imgURL + mess.items[i].img
              }
              str += '<div class="list-imgBar">'
              str += "<img class='list-img' src=" + img + " onerror=javascript:this.src='" + image + "'>";
              str += '</div>'
              //标题
              str += "<div class='list-title'><p class='ell'>" + mess.items[i].title + "</p></div>";
              str += "<div class='list-brief'>" + mess.items[i].area_name + "</div>"
              str += "<div class='list-time'>" + mess.items[i].add_time + "</div>"
              str += "<div class='list-view'><img src='../images/view.png'>"
              str += "<span>" + mess.items[i].click_count + "</span></div>"
              str += "<div class='list-like'><img src='../images/like.png'>"
              str += "<span>" + mess.items[i].likes + "</span></div>"
              str += '</div>'

              //收藏
              str += '<div class="list-collection">'
              str += '<img src="../images/collection.png">'
              str += '<div class="list-number">' + mess.items[i].likes + '</div>'
              str += '</div>'
              str += '</div>'
            }
            else if (modelIndex.mainlistName == 'list-video') {
              //图片
              var img = '';
              var image = '';
              if (mess.items[i].thumb_img == '') {
                img = '../images/base.png'
              } else {
                img = API_URL.imgURL + mess.items[i].thumb_img
                image = API_URL.imgURL + mess.items[i].img
              }
              str += '<div class="list-imgBar">'
              str += "<img class='list-img' src=" + img + " onerror=javascript:this.src='" + image + "'>";
              str += '</div>'
              //是否是视频
              if (mess.items[i].tpe == 5 || mess.items[i].tpe == 4) {
                str += "<div class='listPlay' ><img src='../images/play.png'></div>";
              }
              //标题
              str += "<div class='list-title'><p class='ell'>" + mess.items[i].title + '</p></div>'
              str += '</div>'
            }
          }
        } else {
          str = '<h1>暂无数据</h1>'
          $('.page-show').css('display', 'none')
        }
        $('#' + modelIndex.mainContainerId).html(str);
        MessOpt(page, mess.totalpage, pos, index, 'run', 'ell');
      })
    }
  }
  function direEnter(status, id, index) {

    if (modelIndex.model_api=="getShop") {  //文明积分
      var access_token = $.cookie('TV_CST_TOKEN');
      var ids = $('.active').attr('data-id');
      console.log(ids)
      var param = {
        access_token: access_token,
        goods_id: ids,
      }
      GetDatas('duihuan', param, function (err, res) {
        if (res.code == 0) {
          var message = res.message
          TV.PromptMsg(message)
        } else if (res.code == 10002) {

          if (TV.UserMess(1)) {
            TV.userLogin();
            direEnter(index);
          } else {
            TV.PromptMsg("请重新登陆")
          }
        } else {
          console.log(res)
          var message = res.message
          TV.PromptMsg(message)
        }
      })
      return
    }
    if (modelIndex.model_api == 'getArticleList') {
      var tpe = $('.active').attr('data-tpe');
      if (tpe == 4 || tpe == 5) {
        window.location.href = 'play.html?id=' + $('.active').attr('data-id');
      } else if (tpe == 1 || tpe == 2 || tpe == 3) {
        window.location.href = modelIndex.model_detail+'.html?id=' + $('.active').attr('data-id') + '&type=' + $(
          '.focus_menu').attr('data-id');
      }
    }
    
  }
</script>
<script type="text/javascript" src="../js/twoPageList-1.js"></script>

</html>